package com.jt.controller;

import com.jt.pojo.Message;
import com.jt.service.MessageService;
import com.jt.vo.PageResult;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author shaohe_zhang
 * @Date 2021/12/10 13:17
 * @Version 1.0.0
 */

@RestController
@CrossOrigin
@RequestMapping("/message")
public class MessageController {
    @Autowired
    private MessageService messageService;

    //获取评论信息列表
    @GetMapping("/getMessageList")
    public SysResult getMessageList(PageResult pageResult){
        pageResult = messageService.getMessageList(pageResult);
        return SysResult.success(pageResult);
    }

    //新增留言信息
    @PostMapping("/saveMessage")
    public SysResult saveMessage(@RequestBody Message message){
        messageService.saveMessage(message);
        return SysResult.success();
    }
    //通过id删除评论信息
    @DeleteMapping("/deleteMessageById")
    public SysResult deleteMessageById(Integer id){
        messageService.deleteMessageById(id);
        return SysResult.success();
    }

    //通过id修改评论信息
    @PutMapping("/updateMessageById")
    public SysResult updateMessageById(@RequestBody Message message){
        messageService.updateMessageById(message);
        return SysResult.success();
    }

}
